package com.lipaluma.example.clients.dao.impl;

import java.util.List;

import javax.persistence.Query;

import org.springframework.stereotype.Repository;

import com.lipaluma.example.clients.dao.IOrderDAO;
import com.lipaluma.example.clients.dao.utils.AbstractDao;
import com.lipaluma.example.clients.model.Account;
import com.lipaluma.example.clients.model.Order;

@Repository
public class OrderDAO extends AbstractDao<Order> implements IOrderDAO {

	@Override
	public List<Order> getLastOrdersCreatedForAccount(Long idAccount) {
		Query query = em.createNamedQuery("Orders.findLastCreatedForAccount");
		Account account = new Account();
		account.setId(idAccount);
		query.setParameter("account", account);
		return query.getResultList();
	}
	
}
